import 'package:json_annotation/json_annotation.dart';
import 'package:zywz/models/user_company.dart';

@JsonSerializable()
class CompanyData {
  List<AppCompanyDto> content;
  bool last;
  String? totalElements;
  String? totalPages;

  CompanyData({
    required this.content,
    required this.last,
    this.totalElements,
    this.totalPages,
  });

  factory CompanyData.fromJson(Map<String, dynamic> json) {
    return CompanyData(
      content: (json['content'] as List<dynamic>)
          .map((e) => AppCompanyDto.fromJson(e as Map<String, dynamic>))
          .toList(),
      last: json['last'] as bool,
      totalElements: json['totalElements']?.toString(),
      totalPages: json['totalPages']?.toString(),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'content': content.map((e) => e.toJson()).toList(),
      'last': last,
      'totalElements': totalElements,
      'totalPages': totalPages,
    };
  }
}
